from unihiker import GUI
import sys
import os
u_gui=GUI()
surprised = 0

def button_click1():
    global n
    global c
    c = 0
    global input_calc
    input_calc = (str(""))
    display.config(text=input_calc)
def button_click2():
    global input_calc
    input_calc = (str(input_calc) + str("7"))
    display.config(text=input_calc)
def button_click3():
    global input_calc
    input_calc = (str(input_calc) + str("4"))
    display.config(text=input_calc)
def button_click7():
    global input_calc
    input_calc = (str(input_calc) + str("8"))
    display.config(text=input_calc)
def on_buttonb_click_callback():
    global them
    them = them - 1
    if them == 0:
        them = 3
def button_click4():
    global input_calc
    input_calc = (str(input_calc) + str((0 + 1)))
    display.config(text=input_calc)
def on_buttona_click_callback():
    global them
    them = them + 1
    if them == 4:
        them = 1
def button_click9():
    global input_calc
    input_calc = (str(input_calc) + str("2"))
    display.config(text=input_calc)
def button_click5():
    global input_calc
    input_calc = (str(input_calc) + str("0"))
    display.config(text=input_calc)
def button_click18():
    u_gui.clear()
    u_gui.draw_image(image="Easter_egg.jpeg",x=0,y=0)
    u_gui.draw_text(text="AUTUMNの窝",x=30,y=30,font_size=20, color="#000000")
    u_gui.draw_text(text="加入我们！",x=60,y=60,font_size=20, color="#000000")
    u_gui.draw_qr_code(text="https://yy47068186.yicp",x=70,y=100,w=100)
    u_gui.add_button(text="返回",x=5,y=260,w=50,h=40,onclick=button_click19)
    u_gui.add_button(text="彩蛋？", x=185, y=260, w=50, h=40, onclick=button_click20)
def button_click8():
    global input_calc
    input_calc = (str(input_calc) + str("5"))
    display.config(text=input_calc)
def button_click11():
    global input_calc
    input_calc = (str(input_calc) + str("9"))
    display.config(text=input_calc)
def button_click19():
    u_gui.clear()
    def restart_program():
        python = sys.executable
        os.execl(python, python, * sys.argv)
    if __name__ == "__main__":
    #    time.sleep(3)
        restart_program()
def button_click20():
    global surprised
    surprised = surprised + 1
    if surprised == 5:
        u_gui.clear()
        u_gui.draw_image(image="Easter_egg.jpeg",x=0,y=0)
        u_gui.draw_text(text="曾家乐，我喜欢你", x=10, y=30, font_size=20, color="#000000")
        u_gui.add_button(text="返回", x=5, y=260, w=50, h=40, onclick=button_click19)
def button_click12():
    global input_calc
    input_calc = (str(input_calc) + str("6"))
    display.config(text=input_calc)
def button_click13():
    global input_calc
    input_calc = (str(input_calc) + str("3"))
    display.config(text=input_calc)
def button_click14():
    global input_calc
    input_calc = (str(input_calc) + str("."))
    display.config(text=input_calc)
def button_click16():
    global a
    global input_calc
    global oper
    a = (float(input_calc))
    input_calc = (str(""))
    oper = 1
    display.config(text=(str("+")))
def button_click10():
    global a
    global input_calc
    global oper
    a = (float(input_calc))
    input_calc = (str(""))
    oper = 3
    display.config(text=(str("×")))
def button_click15():
    global a
    global input_calc
    global oper
    a = (float(input_calc))
    input_calc = (str(""))
    oper = 2
    display.config(text=(str("-")))
def button_click6():
    global a
    global input_calc
    global oper
    a = (float(input_calc))
    input_calc = (str(""))
    oper = 4
    display.config(text=(str("÷")))
def button_click17():
    global a
    global b
    global c
    global input_calc
    global oper
    b = (float(input_calc))
    if oper == 1:
        c = (a + b)
        c = round(c,4)
    if oper == 2:
        c = a - b
        c = round(c,4)
    if oper == 3:
        c = a * b
        c = round(c,4)
    if oper == 4:
        c = a / b
        c = round(c,4)
    display.config(text=c)

u_gui.on_b_click(on_buttonb_click_callback)
u_gui.on_a_click(on_buttona_click_callback)
bgpic=u_gui.draw_image(image="Easter_egg.jpeg",x=0,y=0)
theme=u_gui.draw_text(text="AUTUMN计算器",x=60,y=0,font_size=12, color="#FFFFFF")
box=u_gui.draw_round_rect(x=5,y=24,w=230,h=30,r=2,width=2,color="#141200")
u_gui.add_button(text="C",x=5,y=60,w=50,h=40,onclick=button_click1)
u_gui.add_button(text="7",x=5,y=110,w=50,h=40,onclick=button_click2)
u_gui.add_button(text="4",x=5,y=160,w=50,h=40,onclick=button_click3)
u_gui.add_button(text="1",x=5,y=210,w=50,h=40,onclick=button_click4)
u_gui.add_button(text="0",x=5,y=260,w=110,h=40,onclick=button_click5)
u_gui.add_button(text="/",x=65,y=60,w=50,h=40,onclick=button_click6)
u_gui.add_button(text="8",x=65,y=110,w=50,h=40,onclick=button_click7)
u_gui.add_button(text="5",x=65,y=160,w=50,h=40,onclick=button_click8)
u_gui.add_button(text="2",x=65,y=210,w=50,h=40,onclick=button_click9)
u_gui.add_button(text="*",x=125,y=60,w=50,h=40,onclick=button_click10)
u_gui.add_button(text="9",x=125,y=110,w=50,h=40,onclick=button_click11)
u_gui.add_button(text="6",x=125,y=160,w=50,h=40,onclick=button_click12)
u_gui.add_button(text="3",x=125,y=210,w=50,h=40,onclick=button_click13)
u_gui.add_button(text=".",x=125,y=260,w=50,h=40,onclick=button_click14)
u_gui.add_button(text="-",x=185,y=60,w=50,h=40,onclick=button_click15)
u_gui.add_button(text="+",x=185,y=110,w=50,h=90,onclick=button_click16)
u_gui.add_button(text="=",x=185,y=210,w=50,h=40,onclick=button_click17)
u_gui.add_button(text="关于",x=185,y=260,w=50,h=40,onclick=button_click18)
display=u_gui.draw_text(text=" ",x=230,y=20,font_size=20, color="#000000")
display.config(origin="top_right")
n = 1
a = 0
b = 0
c = 0
input_calc = (str(""))
them = 1

while True:
    if them == 1:
        theme.config(color="#000000")
        box.config(color="#000000")
        bgpic.config(image="Easter_egg.jpeg")
        display.config(color="#000000")
    if them == 2:
        theme.config(color="#FFFFFF")
        box.config(color="#FFFF00")
        bgpic.config(image="bj1.png")
        display.config(color="#FF6666")
    if them == 3:
        display.remove()
        theme.config(color="#330000")
        box.config(color="#FFFFFF")
        bgpic.config(image="bj2.png")
        display.config(color="#0000FF")
    if them == 4:
        theme.config(color="#0000FF")
        box.config(color="#FFFF99")
        bgpic.config(image="bj3.png")
        display.config(color="#000000")